package team.hyznrj.studentsys.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import lombok.extern.slf4j.Slf4j;

/**
 * 实现静态资源的映射
 * 保证能够访问到诸如.js,.css等静态资源
 * @ClassName StaticResourceMapConfiguration
 * @author 郑泽锋
 * @date 2018年4月11日
 */
@Configuration
@Slf4j
public class StaticResourceMapConfiguration extends WebMvcConfigurerAdapter{
	@Value("${HTML_SAVE_PATH}")
	private String HTML_SAVE_PATH;
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		log.info("HTML_SAVE_PATH ="+HTML_SAVE_PATH);
//		registry.addResourceHandler("/js/**").addResourceLocations("file:C://Users/ThinkPad/Desktop/rebuiltSsm/js/");
//		registry.addResourceHandler("/css/**").addResourceLocations("file:C://Users/ThinkPad/Desktop/rebuiltSsm/css");
//		registry.addResourceHandler("/images/**").addResourceLocations("file:C://Users/ThinkPad/Desktop/rebuiltSsm/images");
		registry.addResourceHandler("/**").addResourceLocations(HTML_SAVE_PATH);
//		registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
		registry.addResourceHandler("swagger-ui.html")
				.addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/");
		super.addResourceHandlers(registry);
	}
}
